﻿<%@ Page Title="Cungmuanao.com - Quản lý liên hệ" Language="C#" MasterPageFile="~/Admin/Admin.master" 
   AutoEventWireup="true" CodeFile="ManageContacts.aspx.cs" Inherits="Admin_ManageContacts" %>
<%@ Register Assembly="FredCK.FCKeditorV2" Namespace="FredCK.FCKeditorV2" TagPrefix="FCKeditorV2" %>
<asp:Content ID="Content1" ContentPlaceHolderID="LeftContent" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
<script type="text/javascript" src="../js/nicEdit.js"></script>
<script type="text/javascript">
    bkLib.onDomLoaded(function () {
        nicEditors.allTextAreas()
    });
</script>
<script type="text/javascript">
function SelectAllCheckboxes(spanChk)
 {
   // Added as ASPX uses SPAN for checkbox
   var oItem = spanChk.children;
   var theBox= (spanChk.type=="checkbox") ? spanChk : spanChk.children.item[0];
   xState=theBox.checked;
   elm=theBox.form.elements;

   for(i=0;i<elm.length;i++)
     if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)
     {
       if(elm[i].checked!=xState)
         elm[i].click();
     }
 }
</script>
    <div class="title">Quản lý liên hệ</div>
    <div class="body">
        Chọn :
   <asp:DropDownList ID="ddlTypes" runat="server" AutoPostBack="True">
      <asp:ListItem Value="0" >Tất cả</asp:ListItem>
      <asp:ListItem Value="1" Selected="True">Chưa trả lời</asp:ListItem>
      <asp:ListItem Value="2">Đã trả lời</asp:ListItem>      
   </asp:DropDownList>
   <p> </p>
<asp:GridView ID="gvwContacts" runat="server" AutoGenerateColumns="False" DataSourceID="objAllContacts"
        Width="100%" DataKeyNames="ID" OnSelectedIndexChanged="gvwContacts_SelectedIndexChanged"
        ShowHeader="true" onrowdeleted="gvwContacts_RowDeleted" 
        onrowcommand="gvwContacts_RowCommand" onrowcreated="gvwContacts_RowCreated">
        <Columns>
             <asp:TemplateField ItemStyle-HorizontalAlign="Center" ItemStyle-Width="20px" HeaderStyle-Width="20px" HeaderText="Delete">
                <HeaderTemplate>
                    <input id="chkAll" onclick="javascript:SelectAllCheckboxes(this);" runat="server" type="checkbox" />
                </HeaderTemplate>
                <ItemTemplate>
                    <asp:CheckBox runat="server" ID="chkSelect" ToolTip='<%# Eval("ID") %>' />
                </ItemTemplate>
            </asp:TemplateField>                
            <asp:TemplateField HeaderText="Nga&#768;y">
                <ItemTemplate>
                    <asp:Literal runat="server" ID="lblAddedDate" Text='<%# Eval("AddedDate") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Ng&#432;&#417;&#768;i G&#417;&#777;i">
                <ItemTemplate>
                    <asp:Literal runat="server" ID="lblAddedBy" Text='<%# Eval("AddedBy") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="&#272;i&#803;a Chi&#777;" Visible="false">
                <ItemTemplate>
                    <asp:Literal runat="server" ID="lblAddress" Text='<%# Eval("Address") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="&#272;iê&#803;n Thoa&#803;i">
                <ItemTemplate>
                    <asp:Literal runat="server" ID="lblPhone" Text='<%# Eval("Phone") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Email">
                <ItemTemplate>
                    <asp:Literal runat="server" ID="lblEmail" Text='<%# Eval("Email") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Chu&#777; &#272;ê&#768;" Visible="false">
                <ItemTemplate>
                    <asp:Literal runat="server" ID="lblSubject" Text='<%# Eval("Subject") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Ng&#432;&#417;&#768;i Tra&#777; L&#417;&#768;i">
                <ItemTemplate>
                    <asp:Literal runat="server" ID="lblAnswerBy" Text='<%# Eval("AnswerBy") %>' />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Duyê&#803;t">
            <ItemStyle HorizontalAlign="Center" Width="20px" />
                <ItemTemplate>
                    <asp:CheckBox ID="chkApproved" runat="server" Checked='<%# Eval("Approved") %>' Enabled="False" />
                </ItemTemplate>
            </asp:TemplateField>
            
             <asp:TemplateField HeaderText="Mail">
               <ItemStyle HorizontalAlign="Center" Width="20px" />
                <ItemTemplate>
                    <asp:ImageButton ID="lnbSendMail" ToolTip="Email tr&#7843; l&#7901;i cho ng&#432;&#7901;i liên h&#7879;." AlternateText="view" ImageUrl="~/Images/Email.png"
                        runat="server" CommandName="cmdSendMail" CommandArgument='<%# Eval("ID") %>' />
                </ItemTemplate>                
            </asp:TemplateField>
            
            <asp:CommandField HeaderText="S&#7917;a" ButtonType="Image" SelectImageUrl="~/Images/Edit.gif"
                SelectText="Edit Contact" ShowSelectButton="True">
                <ItemStyle HorizontalAlign="Center" Width="20px" />
            </asp:CommandField>
            <asp:CommandField HeaderText="Xóa" ButtonType="Image" DeleteImageUrl="~/Images/Delete.gif"
                DeleteText="Delete Contact" ShowDeleteButton="True">
                <ItemStyle HorizontalAlign="Center" Width="20px" />
            </asp:CommandField>
        </Columns>
        <EmptyDataTemplate>
            <b>Hiện chưa có liên hệ nào.</b></EmptyDataTemplate>
    </asp:GridView>
    <asp:Button runat="server" ID="btDelete" Text=" Delete " OnClick="btDelete_Click" />
    <asp:ObjectDataSource ID="objAllContacts" runat="server" SelectMethod="ListContact"
        TypeName="BLL.Faq.Contacts" DeleteMethod="DeleteContact">
         <DeleteParameters>
             <asp:Parameter Name="id" Type="Int32" />
         </DeleteParameters>
         <SelectParameters>
        <asp:ControlParameter ControlID="ddlTypes" Name="Approved" Type="Int32" PropertyName="SelectedValue" />
      </SelectParameters>
        </asp:ObjectDataSource>
        
    <p>
    </p>
    <asp:DetailsView ID="dvwContact" runat="server" AutoGenerateRows="False" DataSourceID="objCurrContact"
        Height="" Width="100%" OnItemUpdated="dvwContact_ItemUpdated" DataKeyNames="ID"
        DefaultMode="Edit" OnItemCommand="dvwContact_ItemCommand" OnItemCreated="dvwContact_ItemCreated"
        OnItemDeleted="dvwContact_ItemCreated" 
            onitemupdating="dvwContact_ItemUpdating">
        <FieldHeaderStyle Width="100px" />
        <Fields>
            <asp:BoundField DataField="ID" HeaderText="ID" ReadOnly="True" SortExpression="ID"
                InsertVisible="False" />
            <asp:BoundField DataField="AddedDate" HeaderText="Ngày t&#7841;o" InsertVisible="False"
                ReadOnly="True" SortExpression="AddedDate" />
            <asp:BoundField DataField="AddedBy" HeaderText="Ng&#432;&#7901;i t&#7841;o" InsertVisible="False"
                ReadOnly="True" SortExpression="AddedBy" />
            <asp:TemplateField HeaderText="&#272;i&#803;a Chi&#777;" SortExpression="Address" ConvertEmptyStringToNull="false">
                <ItemTemplate>
                    <asp:Label ID="lblAddress" runat="server" Text='<%# Eval("Address") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtAddress" runat="server" Text='<%# Bind("Address") %>' MaxLength="256"
                        Width="100%"></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="&#272;iê&#803;n Thoa&#803;i" SortExpression="Phone" ConvertEmptyStringToNull="false">
                <ItemTemplate>
                    <asp:Label ID="lblPhone" runat="server" Text='<%# Eval("Phone") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtPhone" runat="server" Text='<%# Bind("Phone") %>' MaxLength="256"
                        Width="100%"></asp:TextBox>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Email (*)" SortExpression="Email">
                <ItemTemplate>
                    <asp:Label ID="lblEmail" runat="server" Text='<%# Eval("Email") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtEmail" runat="server" Text='<%# Bind("Email") %>' MaxLength="256"
                        Width="100%"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="valRequireEmail" runat="server" ControlToValidate="txtEmail"
                        SetFocusOnError="true" Text="B&#7855;t bu&#7897;c nh&#7853;p tiêu &#273;&#7873;." ToolTip="B&#7855;t bu&#7897;c nh&#7853;p tiêu &#273;&#7873;."
                        Display="Dynamic"></asp:RequiredFieldValidator>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tiêu &#272;ê&#768; (*)" SortExpression="Subject">
                <ItemTemplate>
                    <asp:Label ID="lblSubject" runat="server" Text='<%# Eval("Subject") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:TextBox ID="txtSubject" runat="server" Text='<%# Bind("Subject") %>' MaxLength="256"
                        Width="100%"></asp:TextBox>
                    <asp:RequiredFieldValidator ID="valRequireSubject" runat="server" ControlToValidate="txtSubject"
                        SetFocusOnError="true" Text="B&#7855;t bu&#7897;c nh&#7853;p tiêu &#273;&#7873;." ToolTip="B&#7855;t bu&#7897;c nh&#7853;p tiêu &#273;&#7873;."
                        Display="Dynamic"></asp:RequiredFieldValidator>
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Câu Ho&#777;i" SortExpression="Question">
                <ItemTemplate>
                    <asp:Label ID="lblQuestion" runat="server" Text='<%# Eval("Question") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                   <%--<FCKeditorV2:FCKeditor ID="txtQuestion" BasePath="~/fckeditor/" runat="server" Value='<%# Bind("Question") %>' 
                   ToolbarSet="BaoAn_Basic" Height="300px" Width="100%" /> --%>
                   <asp:TextBox ID="txtQuestion" runat="server" Text='<%# Bind("Question") %>' Rows="5" TextMode="MultiLine" Width="100%" MaxLength="4000"></asp:TextBox>                                     
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Tra&#777; L&#417;&#768;i" SortExpression="Answer" ConvertEmptyStringToNull="false">
                <ItemTemplate>
                    <asp:Label ID="lblAnswer" runat="server" Text='<%# Eval("Answer") %>'></asp:Label>
                </ItemTemplate>
                <EditItemTemplate>
                  <%-- <FCKeditorV2:FCKeditor ID="txtAnswer" BasePath="~/fckeditor/" runat="server" Value='<%# Bind("Answer") %>' 
                   ToolbarSet="Basic" Height="300px" Width="100%" /> --%> 
                   <asp:TextBox ID="txtAnswer" runat="server" Text='<%# Bind("Answer") %>' Rows="5" TextMode="MultiLine" Width="100%" MaxLength="4000"></asp:TextBox>                                     
                </EditItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Duy&#7879;t" SortExpression="Approved">
                <ItemTemplate>
                    <asp:CheckBox ID="chkApproved" runat="server" Checked='<%# Eval("Approved") %>' Enabled="False" />
                </ItemTemplate>
                <EditItemTemplate>
                    <asp:CheckBox ID="chkApproved" runat="server" Checked='<%# Bind("Approved") %>' />
                </EditItemTemplate>
            </asp:TemplateField>
          <asp:CommandField ButtonType="Image" CancelImageUrl="~/Images/nhaplai.png" 
              CancelText="Nhập  lại" InsertImageUrl="~/Images/themmoi.png" 
              InsertText="Thêm mới" ShowInsertButton="True" ShowEditButton="True"
              UpdateImageUrl="~/Images/capnhat.png" UpdateText="Cập nhật" />            
        </Fields>
    </asp:DetailsView>
    <asp:ObjectDataSource ID="objCurrContact" runat="server" SelectMethod="GetContact"
        TypeName="BLL.Faq.Contacts" UpdateMethod="UpdateContact">
        <UpdateParameters>
            <asp:Parameter Name="id" Type="Int32" />
            <asp:Parameter Name="address" Type="String" ConvertEmptyStringToNull="false" />
            <asp:Parameter Name="phone" Type="String" ConvertEmptyStringToNull="false"/>
            <asp:Parameter Name="email" Type="String" ConvertEmptyStringToNull="false"/>
            <asp:Parameter Name="subject" Type="String" ConvertEmptyStringToNull="false"/>
            <asp:Parameter Name="question" Type="String" ConvertEmptyStringToNull="false"/>
            <asp:Parameter Name="answerDate" Type="DateTime" ConvertEmptyStringToNull="false"/>
            <asp:Parameter Name="answerBy" Type="String" ConvertEmptyStringToNull="false"/>
            <asp:Parameter Name="answer" Type="String" ConvertEmptyStringToNull="false"/>
            <asp:Parameter Name="approved" Type="Boolean" />
        </UpdateParameters>
        <SelectParameters>
            <asp:ControlParameter ControlID="gvwContacts" Name="ContactID" PropertyName="SelectedValue" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
    </div>
    <div class="bottom"></div>
</asp:Content>

